﻿// armsim.cs
// This program contains code that is no longer used. It used to contain the 
// main method for the command line simulator, but it no longer does =(


using System;
using System.IO;

namespace armsim
{
    /// <summary>
    /// Main class for the arm simulator
    /// </summary>
    class armsim
    {

        static void OldMain(string[] args)
        {
            // stores the commandline options
            var options = new Options();
            
            // parsing object for the command line arguments
            var parser = new CommandLine.CommandLineParser();

            // parses the command line arguments, and partially determines if they are valid
            var parseSuccess = parser.ParseArguments(args, options);

            // finished determine if the command line options are valid
            var optionsStateValid = options.CheckState();

            // Exit the program if the options are not in a valid state
            if (!optionsStateValid)
            {
                Console.WriteLine(options.GetUsage());
                return;
            }

            // Runs the unit tests if the TestFlag is set and then exists the program
            if (options.TestFlag)
            {
                RAMTests.RunTests();
                return;
            }

            if (parseSuccess)
            {
                // Initialize the loader

                VirtualLoader virtualLoader = new VirtualLoader(options.InputFile, options.MemorySize);

                try
                {
                    // Load the program into ram
                    var ram = virtualLoader.Load();

                    // Compute the checksum and print the results
                    Console.WriteLine(@"Checksum: " + ram.CheckSum());
                }
                catch (FileNotFoundException ex)
                {
                    Logger.LogEvent(String.Format("Error: File {0} not found.", ex.FileName));
                    return;
                }

            }

        }

    }

}
